package com.cxyxj.conditional;

import com.cxyxj.conditional.impl.ProductServiceImpl;
import com.cxyxj.conditional.impl.UserServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@Conditional({UserCondition.class})
public class BeanConfig {

    @Bean
    public UserServiceImpl u(){
        UserServiceImpl userService = new UserServiceImpl();
        System.out.println("u = " + userService);
        return userService;
    }

    @Bean
    //@Conditional({ProductCondition.class})
    public ProductServiceImpl p(){
        ProductServiceImpl productService = new ProductServiceImpl();
        System.out.println("p = " + productService);
        return productService;
    }
}
